package com.inspur.controller;

import javax.servlet.http.HttpSession;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.inspur.pojo.user;
import com.inspur.service.userService;


@Controller
public class logincontro {
	@Autowired
	private userService userService;

	@RequestMapping("/logincontro")
	public ModelAndView login(user user,HttpSession session){
		ModelAndView mView = new ModelAndView();
		user checkUser = null;
		if(null != user){
			 checkUser = userService.getUser(user);
		}
		if (null != checkUser) {
			mView.addObject("yes", "恭喜你，登录成功");
			//mv.addObject("user",checkUser );
			session.setAttribute("user", checkUser);
			mView.setViewName("main.jsp");
		} else {
			mView.addObject("no", "用户名密码错误，请重新登录！");
			mView.setViewName("Login.jsp");
		}
		
		return mView;
		
	}
}
